/**
 * Created by LeungZ on 2017/4/5.
 */

class Ctrl {
    constructor($modalInstance, service, appSrv, ctgNotification) {
        'ngInject';
        this._modalInstance = $modalInstance;
        this._appSrv = appSrv;
        this._notification = ctgNotification;
        this.oldTable = service.oldTable;
        this.serviceId = service.serviceId;
        this.dpName = service.dpName;
        this.dpColor = service.color;
        this.rsName = service.newRs.objectMeta.name;
    }

    cancel() {
        this._modalInstance.dismiss('cancel');
    }

    save(){
        this.loading = true;
        this._appSrv.rollback(this).then(()=>{
            this._modalInstance.close();
            this._notification.success('回滚成功.');
        }).catch((data)=>{
            this._notification.error('回滚失败, ' + data.resultMsg);
        }).finally(()=>{
            this.loading = false;
        })
    }
}

export default Ctrl